package com.suxin.okhttp.http.exception;


import com.suxin.okhttp.http.core.request.HttpRequest;

/**
 * @Author: tang
 * @Description:
 * @Date 2024/11/27 14:34
 */
public class HttpException extends RuntimeException {

    private static final long serialVersionUID = 8583990125724273072L;

    private HttpRequest httpRequest;

    /**
     * 构造请求参数失败时调用
     *
     * @param message 错误信息
     * @param cause 引起失败的原始异常
     */
    public HttpException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * 发送请求失败时调用
     *
     * @param httpRequest http请求
     * @param cause 引起失败的原始异常
     */
    public HttpException(HttpRequest httpRequest, Throwable cause) {
        super(String.format("Send Http Request failed,httpRequest[%s]", httpRequest), cause);
        this.httpRequest = httpRequest;
    }

    /**
     * 获取序列化版本UID
     *
     * @return UID
     */
    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    /**
     * 获取HTTP请求
     *
     * @return HTTP请求
     */
    public HttpRequest getHttpRequest() {
        return httpRequest;
    }

}
